<template>
  <div>
    <r-search
      :searchForm="searchForm"
      :searchHandle="searchHandle"
      :searchData="searchData"
    />
    <r-table
      :isSelection="true"
      :isPagination="true"
      :tableData="tableData"
      :tableCols="tableCols"
      :tablePage="tablePage"
      @refresh="init()"
    ></r-table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      searchData: {
        id: "",
        moneyStatus: ""
      },
      searchForm: [
        {
          type: "input",
          prop: "id",
          placeholder: "Order Nnumber",
          width: 150
        },
        {
          type: "select",
          prop: "amountType",
          placeholder: "资金Type",
          width: 150,
          options: [
            {
              label: "线上Recharge",
              value: "1"
            },
            {
              label: "机器Recharge",
              value: "2"
            },
            {
              label: "系统Recharge",
              value: "3"
            },
            {
              label: "购物消费",
              value: "4"
            },
            {
              label: "卡片退卡",
              value: "5"
            }
          ]
        }
      ],
      searchHandle: [
        {
          label: "Search",
          type: "success",
          icon: "el-icon-search",
          handle: e => this.init()
        },
        {
          label: "Reset",
          icon: "el-icon-refresh-right",
          handle: e => this.searchFromReset()
        }
      ],
      tableData: [],
      tableCols: [
        {
          label: "Order Nnumber",
          prop: "id"
          // theme: e => e.status ? 'primary' : 'danger', type: "tag",
        },
        {
          label: "资金Type",
          prop: "type",
          formatter: e => (e.type == 1 ? "支出" : e.type == 2 ? "收入" : "")
        },
        {
          label: "OperationsMoney",
          prop: "changeAmount"
        },
        {
          label: "Remarks",
          prop: "content"
        },
        {
          label: "Operation Time",
          prop: "createdTime",
          width: 160,
          formatter: e =>
            e.createdTime &&
            this.getDeta(+new Date(e.createdTime.replace(/T/g, " ")))
        }
      ],
      tablePage: { limit: 10, page: 1, total: 0 }
    };
  },
  components: {},
  computed: {},
  methods: {
    async init() {
      this.tablePage.offset = this.tablePage.page;

      let param = {
        ...this.tablePage,
        ...this.searchData,
        cardNumber: this.$route.query.id
      };
      let res = await this.api.icLoglist(param);
      if (res) {
        this.tablePage.total = res.data.total;
        this.tableData = res.data.list;
      }
    }
  },
  mounted() {
    this.init();
  }
};
</script>
<style scoped lang="scss"></style>
